package cn.shenlong.portal.mapper;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;

import cn.shenlong.mybatis.BaseMapper;
import cn.shenlong.portal.domain.Member;

public interface MemberMapper extends BaseMapper<Member> {
	/**
	 * 会员登录，返回会员对象
	 * @param loginName 登录名
	 * @param password 密码
	 * @return 会员对象
	 */
	@Select("select t.* from T_DC_MEMBER t where t.LOGIN_NAME=#{loginName} and t.password=#{password}")
	@ResultMap("BaseResultMap")
	public Member login(@Param("loginName")String loginName, @Param("password")String password);
	
	public Long findMemberCountByName(String loginName);
	
	/**
	 * 验证邮箱是否存在
	 * @param email 邮箱
	 * @return
	 */
	@Select("select t.* from T_DC_MEMBER t where t.EMAIL=#{email}")
	@ResultMap("BaseResultMap")
	public Member findByEmail(@Param("email")String email);
	
	/**
	 * 验证邮箱是否存在
	 * @param email 邮箱
	 * @param memberId 过滤掉自己的ID
	 * @return
	 */
	@Select("select t.* from T_DC_MEMBER t where t.EMAIL=#{email} and t.member_Id<>#{memberId}")
	@ResultMap("BaseResultMap")
	public Member findByEmailIgnoreId(@Param("email")String email, @Param("memberId")Long memberId);
	
	public int unbind(Long memberId);
	
	/**
	 * 会员登录，返回会员对象
	 * @param loginName 登录名
	 * @param password 密码
	 * @return 会员对象
	 */
	@Select("select t.* from T_DC_MEMBER t where t.LOGIN_NAME=#{loginName}")
	@ResultMap("BaseResultMap")
	public Member findMemberByName(@Param("loginName")String loginName);
}